import { legacy_createStore,combineReducers, applyMiddleware } from 'redux';
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage' // defaults to localStorage for web
import logger from 'redux-logger'
import thunk from 'redux-thunk'
import { composeWithDevTools } from 'redux-devtools-extension'

import { CollApsedReducer } from '../redux/reducers/CollapsedReducer';
import {CurrentUserReducer} from './reducers/CurrentUserReducer.js'
import { CategoriesReducer } from './reducers/CategoriesReducer.js';
import {RoleListReducer} from './reducers/RoleListReducer.js';
import { RightListReducer } from './reducers/RightListReducer.js';

const rootReducer = combineReducers({
    CollApsedReducer,
    CurrentUserReducer,
    CategoriesReducer,
    RoleListReducer,
    RightListReducer,
})
const persistConfig = {
    key: 'root',
    storage,
    blacklist: ['LoadingReducer'] 
}
const persistedReducer = persistReducer(persistConfig, rootReducer)
const store = legacy_createStore(persistedReducer,composeWithDevTools(applyMiddleware(logger,thunk)));
const persistor = persistStore(store)

export  {store, persistor}
